package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	
	public class TankGun
	{
		//
		public var name:String = "gun";
		//
		private var m_pTexture:BitmapData = null;
		//
		private var m_iMaxRad:Number = 2;//最大角速度
		private var m_iMaxAngle:Number = 180;//最大限制角
		//
		private var m_iStartX:Number = 0; //发射点(flyer产生点) - 实际炮管长度
		private var m_iFlyerMode:int = 0;  //弹道类型(0-直射 1-曲射)
		private var m_iInitSpeed:Number = 2;   //初始速度(随时间降低)
		private var m_iAtkPoint:Number = 0;   //提供的高爆伤害
		private var m_iBrkPoint:Number = 0;   //提供的穿甲能力(随时间降低)
		private var m_iWavPoint:Number = 0;   //提供的碎甲能力
		private var m_iFirePoint:Number= 0;   //提供的燃烧伤害(持续10秒)
		//
		private var m_iMaxGunNum:int = 48;	//最大弹数 
		private var m_iSavedGunNum:int = 48;//储备弹数
		private var m_iGunNum:int = 1;		 //当前弹数
		private var m_iReloadNum:int = 1;	 //再装填补充弹数
		private var m_iReloadTime:int = 100; //再装填时间
		private var m_iReloading:int = 0;	 //剩余再装填时间
		private var m_iFrozenTime:int = 50;	 //发射冷却时间
		//访问方法
		public function get bmpData():BitmapData{
			return m_pTexture;
		}
		public function get width():Number{
			return m_pTexture.width;
		}
		public function get height():Number{
			return m_pTexture.height;
		}
		public function get startX():Number{
			return m_iStartX;
		}
		public function get maxRad():Number{
			return m_iMaxRad;
		}
		public function get maxAngle():Number{
			return m_iMaxAngle;
		}
		public function get flyerMode():int{
			return m_iFlyerMode;
		}
		public function get initSpeed():Number{
			return m_iInitSpeed;
		}
		public function get atk():Number{
			return m_iAtkPoint;
		}
		public function get brk():Number{
			return m_iBrkPoint;
		}
		public function get wav():Number{
			return m_iWavPoint;
		}
		public function get fire():Number{
			return m_iFirePoint;
		}
		//
		public function TankGun( xml:XML )
		{
			var texFileName:String = xml.@file;
			var load:rLoader = new rLoader( texFileName, Init );
			name=xml.@name;
			m_iMaxAngle=xml.@maxAngle;//最大速度
			m_iMaxRad=xml.@maxRad;//最大角速度
			m_iAtkPoint=xml.@atk;//高爆伤害
			m_iBrkPoint=xml.@brk;//穿甲能力
			m_iWavPoint=xml.@wav;//溅射能力
			m_iFirePoint=xml.@fire;//燃烧伤害
			m_iFlyerMode=xml.@mode;//弹道
			m_iStartX=xml.@sx;//炮弹初始位置 -以炮口初始对右为例,产生的炮弹坐标应该是:tank.x+(tank.gunX+startX),则纹理和容器相对距离为tex.width-startX
			//即炮塔装配位置为: (tex.width-startX)-tan.gunX
		}
		//
		private function Init( e:Event ):void{//装载纹理完成后
			var bmp:Bitmap = e.target.content as Bitmap;
			m_pTexture = bmp.bitmapData;
		}

	}
}